package com.javasm.entity.sql;

/**
 * @author WangJie
 * @version 1.0
 * @Description:控制系统登录和显示对应权限的sql
 * @date: 2020/7/16 22:22
 * @since JDK 1.8
 */
public interface LoginManageSql {
    // 根据用户名查询用户信息
    String SELECT_ADMIN_BY_ANAME = "SELECT sa.aid,sa.aname,sa.apwd,sa.aimg,sa.role_id,sa.reg_time,sa.login_time,sa.isvalid,sa.menu_id,sa.remark FROM system_admin sa WHERE sa.isvalid=1 AND sa.aname = ?";

    //更新登陆时间
    String UPDATE_LOGINTIME_BY_ANAME = "UPDATE system_admin sa SET sa.login_time = NOW() WHERE sa.aname = ?";

    // 根据用户所拥有的菜单编号查询菜单列表
    String SELECT_MENU_BY_POWER = "SELECT sp.pid,sp.pname,sp.fid,sp.isshow,sp.url,sp.glyphicon FROM system_power sp WHERE sp.isshow=1 AND sp.pid IN (";

    // 修改账户密码
    String UPDATE_APWD_BY_AID = "UPDATE system_admin sa SET sa.apwd = ? WHERE sa.aid = ?";

    // 分页查询用户信息
    String SELECT_ADMIN_BY_PAGE = "SELECT sa.aid,sa.aname,sa.role_id,sa.reg_time,sa.login_time,sa.isvalid,sa.menu_id,sa.remark FROM system_admin sa LIMIT ?,?";

    // 修改账户信息sql
    String UPDATE_ADMIN_BY_ID = "UPDATE system_admin sa SET sa.aname = ?,sa.role_id = ?,sa.isvalid = ? WHERE sa.aid = ?";

    // 删除账户信息，通过id
    String DELETE_ADMIN_BY_ID = "DELETE FROM system_admin WHERE aid = ?";

    // 新增账户信息
    String INSERT_ADMIN = "INSERT INTO system_admin(aname,apwd,role_id,reg_time,isvalid) VALUES(?,?,?,NOW(),?)";

    // 账户信息总条数查询
    String SELECT_ADMIN_TOTALCOUNT = "SELECT COUNT(1) FROM system_admin";

    // 更新用户权限信息
    String UPDATE_ADMIN_MENU_BY_AID = "UPDATE system_admin sa SET sa.menu_id = ? WHERE sa.aid = ?";
}
